<template>
  <view class="inventions-container">
   
    <!-- 发明列表 -->
    <view class="inventions-list">
      <view v-for="(invention, index) in inventions" 
            :key="index" 
            class="invention-card"
            @click="goToDetail(invention)">
        <view class="invention-content">
          <text class="invention-title">{{ invention.title }}</text>
          <view class="invention-info">
            <text class="invention-description">{{ invention.description }}</text>
            <image :src="url('tool',index,'png')" mode="aspectFit" class="invention-image"></image>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
import { ref } from 'vue';
import { useCounterStore } from '@/stores/counter.js';

const url = $url;
const counterStore = useCounterStore();

// 静态发明数据
const inventions = counterStore.Invention;

function goToDetail(invention) {
  counterStore.setCurrentInvention(invention);
  uni.navigateTo({
    url: `/pages/other/physics/invention-detail`
  });
}
</script>

<style scoped>
.inventions-container {
  min-height: 100vh;
  background-color: #f5f5f5;
  padding-bottom: 20rpx;
}

.header {
  background-color: #4a6670;
  padding: 30rpx;
  margin-bottom: 30rpx;
  box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
}

.title {
  color: white;
  font-size: 40rpx;
  font-weight: bold;
  text-align: center;
  text-shadow: 2rpx 2rpx 4rpx rgba(0, 0, 0, 0.2);
}

.inventions-list {
  display: flex;
  flex-direction: column;
  gap: 30rpx;
  padding: 0 20rpx;
}

.invention-card {
  background-color: #ffffff;
  border-radius: 20rpx;
  padding: 30rpx;
  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  border: 1px solid rgba(74, 102, 112, 0.1);
}

.invention-card:active {
  transform: scale(0.98);
  opacity: 0.9;
}

.invention-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 20rpx;
}

.invention-info {
  display: flex;
  width: 100%;
  align-items: flex-start;
  gap: 20rpx;
}

.invention-title {
  font-size: 36rpx;
  font-weight: bold;
  color: #4a6670;
  position: relative;
  padding-left: 40rpx;
}

.invention-title::before {
  content: "▶";
  position: absolute;
  left: 0;
  color: #4a6670;
}

.invention-description {
  font-size: 28rpx;
  color: #666;
  line-height: 1.6;
  flex: 7;
  padding-right: 20rpx;
}

.invention-image {
  width: 150rpx;
  height: 150rpx;
  flex: 3;
  max-width: 30%;
  border-radius: 12rpx;
  background-color: #f8f8f8;
}

.loading-state,
.empty-state {
  padding: 40rpx;
  text-align: center;
  color: #999;
  font-size: 28rpx;
}
</style> 